from langchain_core.documents import Document
from major.models_manager import embedding_model
documents = [
    Document(
        page_content="Dogs are great companions, known for their loyalty and friendliness.",
        metadata={"source": "mammal-pets-doc"},
    ),
    Document(
        page_content="Cats are independent pets that often enjoy their own space.",
        metadata={"source": "mammal-pets-doc"},
    ),
    Document(
        page_content="Goldfish are popular pets for beginners, requiring relatively simple care.",
        metadata={"source": "fish-pets-doc"},
    ),
    Document(
        page_content="Parrots are intelligent birds capable of mimicking human speech.",
        metadata={"source": "bird-pets-doc"},
    ),
    Document(
        page_content="Rabbits are social animals that need plenty of space to hop around.",
        metadata={"source": "mammal-pets-doc"},
    ),
]









from langchain_chroma import Chroma
# chroma 本地向量数据库

vectorstore = Chroma.from_documents(
    documents, # 包含langchain_docoment的列表
    embedding=embedding_model.get_model(), # 传一个embedding模型
) # 建立文档库

# 检索
a = vectorstore.similarity_search("cat",k=3)

print(a)